package v2tostorage

import (
	"github.com/pkg/errors"
	v2 "github.com/stackrox/rox/generated/api/v2"
	"github.com/stackrox/rox/generated/storage"
	"github.com/stackrox/rox/pkg/utils"
)

func convertVulnerabilityState(state v2.VulnerabilityState) storage.VulnerabilityState {
	switch state {
	case v2.VulnerabilityState_OBSERVED:
		return storage.VulnerabilityState_OBSERVED
	case v2.VulnerabilityState_DEFERRED:
		return storage.VulnerabilityState_DEFERRED
	case v2.VulnerabilityState_FALSE_POSITIVE:
		return storage.VulnerabilityState_FALSE_POSITIVE
	default:
		utils.Should(errors.Errorf("unhandled vulnerability state encountered %s", state))
		return storage.VulnerabilityState_OBSERVED
	}
}
